package com.howj2.springcloud.controller;


import com.howj2.springcloud.pojo.Product;
import com.howj2.springcloud.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
public class ProductController {
 
	@Autowired
    ProductService productService;

	@Value("${version}")
    String version;
	
    @RequestMapping("/products")
    public String products(Model mode) {
    	List<Product> ps = productService.listProducts();
    	mode.addAttribute("ps",ps);
    	mode.addAttribute("version",version);
    	return "products";
    }
}